#include<vector>
using namespace std;

bool increasingTriplet(vector<int>& nums) {
    /*int n = nums.size();
    vector<int> ret;
    ret.push_back(nums[0]);
    for (int i = 1; i < n; i++)
    {
        if (nums[i] > ret.back()) ret.push_back(nums[i]);
        else
        {
            int left = 0, right = ret.size() - 1;
            while (left < right)
            {
                int mid = (left + right) / 2;
                if (nums[i] <= ret[mid]) right = mid;
                else left = mid + 1;
            }
            ret[left] = nums[i];
        }
        if (ret.size() == 3) return true;
    }
    return false;*/

    int n = nums.size();
    int a = nums[0], b = INT_MAX;
    for (int i = 1; i < n; i++)
    {
        if (nums[i] > b) return true;
        if (nums[i] <= a) a = nums[i];
        else if (nums[i] <= b) b = nums[i];
        else return true;
    }
    return false;
}

int lengthOfLIS(vector<int>& nums) {
    int n = nums.size();
    vector<int> ret;
    ret.push_back(nums[0]);
    for (int i = 1; i < n; i++)
    {
        if (nums[i] > ret.back()) ret.push_back(nums[i]);
        else
        {
            int left = 0, right = ret.size() - 1;
            while (left < right)
            {
                int mid = (left + right) / 2;
                if (nums[i] <= ret[mid]) right = mid;
                else left = mid + 1;
            }
            ret[right] = nums[i];
        }
    }
    return ret.size();
}
int findLengthOfLCIS(vector<int>& nums) {
    int n = nums.size();
    vector<int> dp(n, 1);
    int ret = 1;
    for (int i = 1; i < n; i++)
    {
        if (nums[i] > nums[i - 1]) dp[i] = dp[i - 1] + 1;
        ret = max(ret, dp[i]);
    }
    return ret;
}

int main()
{
    vector<int> v{ 3,5,1,3,3,5,7,5,6 };
    increasingTriplet(v);
    lengthOfLIS(v);
    findLengthOfLCIS(v);

	return 0;
}